package com.etl.runner;

import com.etl.sys.entity.*;
import com.etl.sys.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
 * @author: chenfenghai
 * @version: 1.0
 * @date: 2020-10-14 15:00
 */
@Slf4j
@Component
public class ScheduleRunner implements ApplicationRunner {

    @Autowired
    ISysScheduleService sysScheduleService;

    @Override
    public void run(ApplicationArguments args) {
//        CompletableFuture.runAsync(this::startScheduleService);
    }

    public void startScheduleService(){
        List<SysSchedule> scheduleList = sysScheduleService.list();
        scheduleList.parallelStream().forEach(this::buildScheduler);
    }

    private void buildScheduler(SysSchedule sysSchedule) {
        log.debug("{}", sysSchedule);
    }
}
